<script lang="ts" setup>
import { 
    SearchOutlined, 
    RedoOutlined,
    UploadOutlined, 
    DownloadOutlined,
    EditOutlined,
    EyeOutlined,
    DeleteOutlined
} from '@ant-design/icons-vue';
import { ref } from 'vue';
import { mock } from 'mockjs';

const loading = ref<boolean>(false);
const tableData = ref([]);
const selectedRowKeys = ref([]);
const columns = [
    { title: '病案号', dataIndex: 'caseNumber', key: 'caseNumber', align: 'center' },
    { title: '入院记录_登记号', dataIndex: 'admissionRecordNumber', key: 'admissionRecordNumber', align: 'center' },
    { title: '民族', dataIndex: 'ethnicity', key: 'ethnicity', align: 'center' },
    { title: '婚姻', dataIndex: 'maritalStatus', key: 'maritalStatus', align: 'center' },
    { title: '性别', dataIndex: 'gender', key: 'gender', align: 'center' },
    { title: '年龄', dataIndex: 'age', key: 'age', align: 'center' },
    { title: '体格检查-身高', dataIndex: 'height', key: 'height', align: 'center' },
    { title: '体格检查-体重', dataIndex: 'weight', key: 'weight', align: 'center' },
    { title: '既往史-过敏史', dataIndex: 'allergyHistory', key: 'allergyHistory', align: 'center' },
    { title: '个人史-嗜烟', dataIndex: 'smokingHistory', key: 'smokingHistory', align: 'center' },
    { title: '嗜烟平均数', dataIndex: 'averageCigarettesPerDay', key: 'averageCigarettesPerDay', align: 'center' },
    { title: '戒烟', dataIndex: 'quitSmoking', key: 'quitSmoking', align: 'center' },
    { title: '嗜烟时间', dataIndex: 'smokingDuration', key: 'smokingDuration', align: 'center' },
    { title: '嗜酒', dataIndex: 'drinkingHistory', key: 'drinkingHistory', align: 'center' },
    { title: '嗜酒平均数', dataIndex: 'averageAlcoholPerDay', key: 'averageAlcoholPerDay', align: 'center' },
    { title: '嗜酒时间', dataIndex: 'drinkingDuration', key: 'drinkingDuration', align: 'center' },
    { title: '个人史-戒酒', dataIndex: 'quitDrinking', key: 'quitDrinking', align: 'center' },
    { title: '层流研究病房', dataIndex: 'laminarFlowWard', key: 'laminarFlowWard', align: 'center' },
    { title: '传染科医疗单元', dataIndex: 'infectiousDiseaseUnit', key: 'infectiousDiseaseUnit', align: 'center' },
    { title: '创伤医学中心医疗单元', dataIndex: 'traumaCenterUnit', key: 'traumaCenterUnit', align: 'center' },
    { title: '胆道外科病房', dataIndex: 'biliarySurgeryWard', key: 'biliarySurgeryWard', align: 'center' },
    { title: '耳鼻咽喉-头颈外科医疗单元', dataIndex: 'entHeadNeckSurgeryUnit', key: 'entHeadNeckSurgeryUnit', align: 'center' },
    { title: '肺癌中心医疗单元', dataIndex: 'lungCancerCenterUnit', key: 'lungCancerCenterUnit', align: 'center' },
    { title: '风湿免疫科医疗单元', dataIndex: 'rheumatologyUnit', key: 'rheumatologyUnit', align: 'center' },
    { title: '腹部肿瘤病房', dataIndex: 'abdominalTumorWard', key: 'abdominalTumorWard', align: 'center' },
    { title: '肝脏外科病房', dataIndex: 'liverSurgeryWard', key: 'liverSurgeryWard', align: 'center' },
    { title: '肝移植中心', dataIndex: 'liverTransplantCenter', key: 'liverTransplantCenter', align: 'center' },
    { title: '感染科医疗单元', dataIndex: 'infectionUnit', key: 'infectionUnit', align: 'center' },
    { title: '骨科医疗单元', dataIndex: 'orthopedicsUnit', key: 'orthopedicsUnit', align: 'center' },
    { title: '呼吸与危重症医学科医疗单元', dataIndex: 'respiratoryCriticalCareUnit', key: 'respiratoryCriticalCareUnit', align: 'center' },
    { title: '甲状腺外科病房', dataIndex: 'thyroidSurgeryWard', key: 'thyroidSurgeryWard', align: 'center' },
    { title: '结核医疗单元', dataIndex: 'tuberculosisUnit', key: 'tuberculosisUnit', align: 'center' },
    { title: '结直肠肿瘤中心医疗单元', dataIndex: 'colorectalCancerCenterUnit', key: 'colorectalCancerCenterUnit', align: 'center' },
    { title: '康复医学科医疗单元', dataIndex: 'rehabilitationUnit', key: 'rehabilitationUnit', align: 'center' },
    { title: '老年医学中心/干部医疗科医疗单元', dataIndex: 'geriatricCenterUnit', key: 'geriatricCenterUnit', align: 'center' },
    { title: '泌尿外科医疗单元', dataIndex: 'urologyUnit', key: 'urologyUnit', align: 'center' },
    { title: '内分泌代谢科医疗单元', dataIndex: 'endocrinologyUnit', key: 'endocrinologyUnit', align: 'center' },
    { title: '皮肤性病科医疗单元', dataIndex: 'dermatologyUnit', key: 'dermatologyUnit', align: 'center' },
    { title: '全科（特需）病房', dataIndex: 'generalWard', key: 'generalWard', align: 'center' },
    { title: '乳腺疾病中心医疗单元', dataIndex: 'breastDiseaseCenterUnit', key: 'breastDiseaseCenterUnit', align: 'center' },
    { title: '神经内科医疗单元', dataIndex: 'neurologyUnit', key: 'neurologyUnit', align: 'center' },
    { title: '神经外科医疗单元', dataIndex: 'neurosurgeryUnit', key: 'neurosurgeryUnit', align: 'center' },
    { title: '肾脏内科医疗单元', dataIndex: 'nephrologyUnit', key: 'nephrologyUnit', align: 'center' },
    { title: '生物治疗研究病房', dataIndex: 'biotherapyWard', key: 'biotherapyWard', align: 'center' },
    { title: '疼痛科医疗单元', dataIndex: 'painManagementUnit', key: 'painManagementUnit', align: 'center' },
    { title: '头颈肿瘤病房', dataIndex: 'headNeckTumorWard', key: 'headNeckTumorWard', align: 'center' },
    { title: '胃癌中心医疗单元', dataIndex: 'gastricCancerCenterUnit', key: 'gastricCancerCenterUnit', align: 'center' },
    { title: '胃肠外科病房', dataIndex: 'gastrointestinalSurgeryWard', key: 'gastrointestinalSurgeryWard', align: 'center' },
    { title: '消化内科医疗单元', dataIndex: 'gastroenterologyUnit', key: 'gastroenterologyUnit', align: 'center' },
    { title: '心理卫生中心医疗单元', dataIndex: 'mentalHealthCenterUnit', key: 'mentalHealthCenterUnit', align: 'center' },
    { title: '心脏大血管外科医疗单元', dataIndex: 'cardiovascularSurgeryUnit', key: 'cardiovascularSurgeryUnit', align: 'center' },
    { title: '心脏内科医疗单元', dataIndex: 'cardiologyUnit', key: 'cardiologyUnit', align: 'center' },
    { title: '胸部肿瘤病房', dataIndex: 'thoracicTumorWard', key: 'thoracicTumorWard', align: 'center' },
    { title: '胸外科医疗单元', dataIndex: 'thoracicSurgeryUnit', key: 'thoracicSurgeryUnit', align: 'center' },
    { title: '血管外科病房', dataIndex: 'vascularSurgeryWard', key: 'vascularSurgeryWard', align: 'center' },
    { title: '血液内科医疗单元', dataIndex: 'hematologyUnit', key: 'hematologyUnit', align: 'center' },
    { title: '眼科医疗单元', dataIndex: 'ophthalmologyUnit', key: 'ophthalmologyUnit', align: 'center' },
    { title: '胰腺外科病房', dataIndex: 'pancreaticSurgeryWard', key: 'pancreaticSurgeryWard', align: 'center' },
    { title: '胰腺炎中心医疗单元', dataIndex: 'pancreatitisCenterUnit', key: 'pancreatitisCenterUnit', align: 'center' },
    { title: '整形外科/烧伤科医疗单元', dataIndex: 'plasticBurnSurgeryUnit', key: 'plasticBurnSurgeryUnit', align: 'center' },
    { title: '中西医结合内科医疗单元', dataIndex: 'integrativeMedicineUnit', key: 'integrativeMedicineUnit', align: 'center' },
    { title: '肿瘤日间医疗单元', dataIndex: 'oncologyDayUnit', key: 'oncologyDayUnit', align: 'center' },
    { title: '重症医学科医疗单元', dataIndex: 'criticalCareUnit', key: 'criticalCareUnit', align: 'center' }
];
const mockData = mock({
    'data|10': [
        {
            'id|+1': 1,
            caseNumber: '@string("number", 8)',
            admissionRecordNumber: '@string("number", 8)',
            ethnicity: '@cword("汉族壮族满族回族苗族维吾尔族土家族彝族蒙古族藏族布依族侗族瑶族朝鲜族白族哈尼族哈萨克族黎族傣族畲族傈僳族仡佬族东乡族高山族拉祜族水族佤族纳西族羌族土族仫佬族锡伯族柯尔克孜族达斡尔族景颇族毛南族撒拉族布朗族塔吉克族阿昌族普米族鄂温克族怒族京族基诺族德昂族保安族俄罗斯族裕固族乌孜别克族门巴族鄂伦春族独龙族塔塔尔族赫哲族珞巴族", 2, 3)',
            maritalStatus: '@pick(["未婚", "已婚", "离异", "丧偶"])',
            gender: '@pick(["男", "女"])',
            age: '@integer(1, 100)',
            height: '@integer(150, 200)',
            weight: '@integer(40, 100)',
            allergyHistory: '@cword("无青霉素过敏花粉过敏海鲜过敏", 2, 4)',
            smokingHistory: '@pick(["是", "否"])',
            averageCigarettesPerDay: '@integer(0, 40)',
            quitSmoking: '@pick(["是", "否"])',
            smokingDuration: '@integer(0, 50)',
            drinkingHistory: '@pick(["是", "否"])',
            averageAlcoholPerDay: '@integer(0, 10)',
            drinkingDuration: '@integer(0, 50)',
            quitDrinking: '@pick(["是", "否"])',
            laminarFlowWard: '@pick(["是", "否"])',
            infectiousDiseaseUnit: '@pick(["是", "否"])',
            traumaCenterUnit: '@pick(["是", "否"])',
            biliarySurgeryWard: '@pick(["是", "否"])',
            entHeadNeckSurgeryUnit: '@pick(["是", "否"])',
            lungCancerCenterUnit: '@pick(["是", "否"])',
            rheumatologyUnit: '@pick(["是", "否"])',
            abdominalTumorWard: '@pick(["是", "否"])',
            liverSurgeryWard: '@pick(["是", "否"])',
            liverTransplantCenter: '@pick(["是", "否"])',
            infectionUnit: '@pick(["是", "否"])',
            orthopedicsUnit: '@pick(["是", "否"])',
            respiratoryCriticalCareUnit: '@pick(["是", "否"])',
            thyroidSurgeryWard: '@pick(["是", "否"])',
            tuberculosisUnit: '@pick(["是", "否"])',
            colorectalCancerCenterUnit: '@pick(["是", "否"])',
            rehabilitationUnit: '@pick(["是", "否"])',
            geriatricCenterUnit: '@pick(["是", "否"])',
            urologyUnit: '@pick(["是", "否"])',
            endocrinologyUnit: '@pick(["是", "否"])',
            dermatologyUnit: '@pick(["是", "否"])',
            generalWard: '@pick(["是", "否"])',
            breastDiseaseCenterUnit: '@pick(["是", "否"])',
            neurologyUnit: '@pick(["是", "否"])',
            neurosurgeryUnit: '@pick(["是", "否"])',
            nephrologyUnit: '@pick(["是", "否"])',
            biotherapyWard: '@pick(["是", "否"])',
            painManagementUnit: '@pick(["是", "否"])',
            headNeckTumorWard: '@pick(["是", "否"])',
            gastricCancerCenterUnit: '@pick(["是", "否"])',
            gastrointestinalSurgeryWard: '@pick(["是", "否"])',
            gastroenterologyUnit: '@pick(["是", "否"])',
            mentalHealthCenterUnit: '@pick(["是", "否"])',
            cardiovascularSurgeryUnit: '@pick(["是", "否"])',
            cardiologyUnit: '@pick(["是", "否"])',
            thoracicTumorWard: '@pick(["是", "否"])',
            thoracicSurgeryUnit: '@pick(["是", "否"])',
            vascularSurgeryWard: '@pick(["是", "否"])',
            hematologyUnit: '@pick(["是", "否"])',
            ophthalmologyUnit: '@pick(["是", "否"])',
            pancreaticSurgeryWard: '@pick(["是", "否"])',
            pancreatitisCenterUnit: '@pick(["是", "否"])',
            plasticBurnSurgeryUnit: '@pick(["是", "否"])',
            integrativeMedicineUnit: '@pick(["是", "否"])',
            oncologyDayUnit: '@pick(["是", "否"])',
            criticalCareUnit: '@pick(["是", "否"])'
        }
    ]
}).data;

tableData.value = mockData;
</script>

<template>
    <div>
        <a-card title="检索" size="small">
            <a-form layout="inline">
                <a-form-item label="登记号">
                    <a-input placeholder="请输入登记号" :disabled="loading" />
                </a-form-item>
                <a-form-item label="病案号">
                    <a-input placeholder="请输入病案号" :disabled="loading" />
                </a-form-item>
                <a-form-item label="就诊ID">
                    <a-input placeholder="请输入就诊ID" :disabled="loading" />
                </a-form-item>
                <a-form-item>
                    <a-space>
                        <a-button type="primary" :loading="loading">
                            <template #icon>
                                <SearchOutlined />
                            </template>
                            检索
                        </a-button>
                        <a-button :loading="loading">
                            <template #icon>
                                <RedoOutlined />
                            </template>
                            重置
                        </a-button>
                    </a-space>
                </a-form-item>
            </a-form>
        </a-card>
        <a-card title="列表" size="small" style="margin-top: 14px">
            <a-table 
                rowKey="id" 
                size="middle" 
                :bordered="false" 
                :loading="loading" 
                :columns="columns"
                :data-source="tableData" :scroll="{ x: 'max-content' }"
                :row-class-name="(_record: any, index: number) => (index % 2 === 1 ? 'table-striped' : null)"
            >
                <template #title>
                    <a-space>
                        <a-button type="primary">
                            <template #icon><UploadOutlined /></template>
                            导入患者数据
                        </a-button>
                        <a-button>
                            <template #icon><DownloadOutlined /></template>
                            导出患者数据
                        </a-button>
                        <a-button type="primary" danger ghost :disabled="selectedRowKeys.length === 0">
                            <template #icon><DeleteOutlined /></template>
                            批量删除
                        </a-button>
                    </a-space>
                </template>
                <template #bodyCell="{ column, record }">
                    <template v-if="column.key === 'actions'">
                        <a-space>
                            <a-button size="small" type="primary" ghost>
                                <template #icon><EditOutlined /></template>
                                编辑
                            </a-button>
                            <a-button size="small" type="primary" danger ghost>
                                <template #icon><DeleteOutlined /></template>
                                删除
                            </a-button>
                            <a-button size="small">
                                <template #icon><EyeOutlined /></template>
                                查看
                            </a-button>
                        </a-space>
                    </template>
                </template>
            </a-table>
        </a-card>
    </div>
</template>

<style lang="less" scoped>
.page-name {
    font-size: 20px;
    color: #333;
    font-weight: bold;
}

:deep(.table-striped) {
    background-color: @second-bg-color;
}
</style>